package qnautil;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBUtil {
	static{
		try{
			Class.forName("oracle.jdbc.driver.OracleDriver");
		}catch(ClassNotFoundException e){
			e.printStackTrace();
		}
	}
	public static Connection getConnection(){
		String url = "jdbc:oracle:thin:@localhost:1521:xe";
		String user = "HR";
		String pwd = "1234";
		Connection con = null;
		try{
			con = DriverManager.getConnection(url,user,pwd);
		}catch(SQLException ee){
			ee.printStackTrace();
		}
		return con;
	}
	public static void close(Connection con, Statement stmt, ResultSet rs){
		try{
			if(con != null) con.close();
			if(stmt != null) stmt.close();
			if(rs != null) rs.close();			
		}catch(SQLException eee){
			eee.printStackTrace();
		}
	}
}